package formulation.controllers;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import db.standard.classification.Classification;
import db.standard.classification.ClassificationService;

public class ClassificationController extends MultiActionController
{
    private ClassificationService classificationService;
    
    public void setClassificationService(ClassificationService classificationService) {
        this.classificationService = classificationService;
    }
    
    public ModelAndView add(HttpServletRequest request,
            HttpServletResponse response, Classification classification)
    {
        classificationService.insert(classification);
        return new ModelAndView("redirect:list.do");
    }
    
    public ModelAndView remove(HttpServletRequest request,
            HttpServletResponse response, Classification classification)
    {
        classificationService.remove(classification.getId());
        return new ModelAndView("redirect:list.do");
    }
    
    public ModelAndView list(HttpServletRequest request,
            HttpServletResponse response)
    {
        return new ModelAndView("classification/classification", "classifications", classificationService.list());
    }
}
